package com.av.bcacc.jetpack.viewmodel;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.av.bcacc.jetpack.R;
import com.av.bcacc.jetpack.databinding.ActivityScreenOrientationBinding;

public class ScreenOrientationActivity extends AppCompatActivity {

    public int number;

    ActivityScreenOrientationBinding orientationBinding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        orientationBinding= DataBindingUtil.setContentView(this, R.layout.activity_screen_orientation);
//        setContentView(R.layout.activity_screen_orientation);
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onCreate.....");
        if(savedInstanceState!=null){
            number= savedInstanceState.getInt("numberValue",0);
            orientationBinding.textView4.setText(String.valueOf(number));
        }
        orientationBinding.button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                number++;
                orientationBinding.textView4.setText(String.valueOf(number));
            }
        });
    }
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onSaveInstanceState.....");
        outState.putInt("numberValue",number);
    }
    @Override
    protected void onStart() {
        super.onStart();
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onStart.....");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onResume.....");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onPause.....");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onStop.....");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onDestroy.....");
    }



    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Log.d(ScreenOrientationActivity.class.getSimpleName(),"onConfigurationChanged.....");
    }
}
